package com.ch.playandroid.webView

import androidx.activity.viewModels
import androidx.fragment.app.commit
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.ch.common.base.activity.BaseActivity
import com.ch.common.constant.ConstantValue
import com.ch.playandroid.R
import com.ch.playandroid.databinding.AppActivityWebviewBinding

@Route(path = ConstantValue.PATH_WEB_VIEW)
class PlayWebViewActivity : BaseActivity<WebViewModel, AppActivityWebviewBinding>() {
    @Autowired(name = ConstantValue.ACTION_KEY_TITLE)
    @JvmField
    var getTitle = ""

    @Autowired(name = ConstantValue.ACTION_KEY_URL)
    @JvmField
    var getUrl: String = ""

    private val webFragment: WebFragment by lazy {
        WebFragment.actionCrate()
    }


    override fun getLayoutResID(): Int {
        return R.layout.app_activity_webview
    }

    override fun initView() {
        mBinding.toolbar.title = getTitle
        viewModel.setUrl(getUrl)
        supportFragmentManager.commit {
            setReorderingAllowed(true)
            replace(R.id.web_fcv, webFragment)
        }
    }

    override val viewModel: WebViewModel by viewModels()

    override fun bindViewModel() {
        mBinding.viewModel = viewModel
    }

    override fun initObserve() {

    }
}